![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
@analytics/storage-utils
Advanced tools
A tiny storage utility library with fallback mechanism in 1017 bytes
.
By default, @analytics/storage-utils
will persist values in browser in this order:
localStorage
localStorage
, use cookies
cookies
, use sessionStorage
sessionStorage
, use global
windowIf you want to specify which storage mechanism to use, use the options
parameter.
setItem
Set a value.
import { setItem } from '@analytics/storage-utils'
/**
* Basic usage
*/
/* Save value to `localStorage` or `cookies` or `global` */
setItem('key', 'value')
// { value: "value", oldValue: "old", location: "localStorage" }
/** Setting values to specific location */
/* Set value to specifically localStorage */
setItem('key', 'otherValue', { storage: 'localStorage' })
// { value: "otherValue", oldValue: "value", location: "localStorage" }
/* Set value to specifically cookie */
setItem('keyTwo', 'cookieVal', { storage: 'cookie' })
// { value: "cookieVal", oldValue: "null", location: "cookie" }
/* Set value from specifically sessionStorage */
setItem('keyThree', 'xyz', { storage: 'sessionStorage' })
// { value: "cookieVal", oldValue: "null", location: "sessionStorage" }
/* Set value from specifically the global window (or global this in node.js) */
setItem('keyThree', 'xyz', { storage: 'global' })
// { value: "cookieVal", oldValue: "null", location: "cookie" }
getItem
Get a value.
import { getItem } from '@analytics/storage-utils'
/* Basic usage */
/* Lookup value from `localStorage` or `cookies` or `global` */
const value = getItem('key')
/**
* Getting values to specific locations
*/
// Get value to specifically localStorage
const getLocalStorageValue = getItem('key', { storage: 'localStorage' })
/* Get value to specifically cookie */
const getCookieValue = getItem('key', { storage: 'cookie' })
// Get value to specifically sessionStorage
const getSessionStorageValue = getItem('key', { storage: 'sessionStorage' })
/* Get value from specifically the global window (or global this in node.js) */
const getGlobalValue = getItem('key', { storage: 'global' })
/* Get value from all locations */
const valueObj = getItem('otherKey', { storage: '*' })
// { cookie: undefined, localStorage: "hahaha", global: null }
removeItem
Remote a value.
import { removeItem } from '@analytics/storage-utils'
/* Basic usage */
// Will try remove value from `localStorage` -> `cookies` -> `global`
removeItem('key')
/** Removing values to specific locations */
/* Remove value to specifically localStorage */
removeItem('key', { storage: 'localStorage' })
/* Remove value to specifically cookie */
removeItem('keyTwo', { storage: 'cookie' })
/* Remove value to specifically sessionStorage */
removeItem('key', { storage: 'sessionStorage' })
/* Remove value to specifically global */
removeItem('keyThree', { storage: 'global' })
/* Remove value from all locations */
removeItem('otherKey', { storage: '*' })
FAQs
Storage utility with fallbacks
We found that @analytics/storage-utils demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.